package com.home.s2g.controller;

import com.home.s2g.entities.Controllable;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

/**
 * Created by IntelliJ IDEA.
 * User: Zinolis
 * Date: 12/17/11
 * Time: 5:59 PM
 * To change this template use File | Settings | File Templates.
 */
public class PlayerController implements Controller {

    private Controllable controllable;

    @Override
    public void setControllable(Controllable controllable) {
        this.controllable = controllable;
    }


    private class KeyBoardController implements KeyListener {

        @Override
        public void keyTyped(KeyEvent e) {
            switch (e.getKeyCode()) {
                case KeyEvent.VK_RIGHT: {
                    controllable.setLocation(controllable.getLocation().x += 1, controllable.getLocation().y);
                }
                break;
                case KeyEvent.VK_LEFT: {
                    controllable.setLocation(controllable.getLocation().x -= 1, controllable.getLocation().y);
                }
                break;
                default:
                    e.consume();
            }
        }

        @Override
        public void keyPressed(KeyEvent e) {
            //To change body of implemented methods use File | Settings | File Templates.
        }

        @Override
        public void keyReleased(KeyEvent e) {
            //To change body of implemented methods use File | Settings | File Templates.
        }
    }
}
